package com.wm.wmim.common.exception;

import com.wm.wmim.common.constant.HttpStatusConstant;
import com.wm.wmim.common.enums.BizCodeEnum;
import lombok.Getter;
import org.springframework.http.HttpStatus;

/**
 * @author weiming
 * @date 2024/12/27 22:49
 * @description
 */
@Getter
public class BusinessException extends RuntimeException{

    private String code;
    private String msg;
    private Integer httpStatus;

    public BusinessException(String code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
        this.httpStatus = HttpStatus.BAD_REQUEST.value();
    }

    public BusinessException(BizCodeEnum bizCodeEnum) {
        this(bizCodeEnum.getCode(), bizCodeEnum.getMsg());
        this.httpStatus = bizCodeEnum.getHttpStatus();
    }
}
